package com.k.kpp.logback;

/**
 * @author KK
 */
public enum LogLevel {

    TRACE(0,"TRACE"),DEBUG(1,"DEBUG"),INFO(2,"INFO"),WARN(3,"WARN"),ERROR(4,"ERROR"),DEFAULT(1,"DEBUG");

    LogLevel(int i, String s){
        levelInt=i;
        levelStr=s;
    }

    private int levelInt;

    private String levelStr;

    public int getLevelInt() {
        return levelInt;
    }

    public String getLevelStr() {
        return levelStr;
    }

    public static String findStrByInt(int i){
        for (LogLevel item : LogLevel.values()) {
            if (item.getLevelInt() == i) {
                return item.getLevelStr();
            }
        }
        return DEFAULT.getLevelStr();
    }

    public static int findIntByStr(String str){
        for (LogLevel item : LogLevel.values()) {
            if (item.getLevelStr().equals(str.toUpperCase())) {
                return item.getLevelInt();
            }
        }
        return DEFAULT.getLevelInt();
    }
}